﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LazyLoad.aspx.cs" Inherits="Test.LazyLoad" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../css/index.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery-1.4.4.min.js" type="text/javascript"></script>
    <script src="../js/jq/jquery/jquery.extend.js" type="text/javascript"></script>
    <script src="../js/jq/CommonJquery/com_method.js" type="text/javascript"></script>
    <script type="text/javascript">
        var bufferCount = 0;
        var isLoaded = false;
        var ishashchange = false;
        function ajaxTest(firstLoad) {
            url = "WebAjaxTest.aspx/ajaxTest";
            bufferCount++;
            isLoaded = false;
            $.ajaxForPost(url,
                            "{ bufferCount:'" + bufferCount + "'}",
                           function () {
                           },
                          function (data) {
                              if (data.d == 'no') {
                                  $("#loadMB1").remove();
                                  $("<div>没数据了</div>").appendTo($("#divContainer"));
                              }
                              else {
                                  $(data.d).appendTo($("#divContainer"));
                                  $("#loadMB").remove();
                                  if (firstLoad) {
                                  }
                                  else {
                                      $("#loadMB1").remove();
                                  }
                                  isLoaded = true;
                                  return true;
                              }
                          });
        }
        $(document).ready(function () {
            ajaxTest(true);
            $(window).scroll(function () {
                if ($("#loadMB1")[0]) {
                    if ($(this).scrollTop() + $(this).height() > $("#loadMB1").offset().top) {
                        if (isLoaded) {
                            ajaxTest();
                        }
                    }
                    else {

                    }
                }
            });
        });
       
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="divContainer">
    </div>
    </form>
</body>
</html>
